package tw.com.softleader.reins.demo.smartphone.service;

import java.util.ArrayList;
import java.util.List;

import tw.com.softleader.reins.demo.smartphone.entity.SmartPhone;

public class SmartPhoneService {
	List<SmartPhone> smartPhones = new ArrayList<SmartPhone>();

	public SmartPhoneService() {
		initial();
	}
	
	public List<SmartPhone> selectAll() {
		return smartPhones;
	}

	public SmartPhone selectById(Long id) {
		for (SmartPhone smartPhone : smartPhones) {
			if (smartPhone.getId() == id) {
				return smartPhone;
			}
		}
		return null;
	}

	private void initial() {
		SmartPhone smartPhone1 = new SmartPhone();
		smartPhone1.setId(1L);
		smartPhone1.setName("ASUS ZenFone5 16G");
		smartPhone1.setCpu("Intel Atom Z2580 2.0GHz");
		smartPhone1.setResWidth(1280);
		smartPhone1.setResHeight(720);
		smartPhone1.setSystem("Android 4.3 JellyBean");
		smartPhones.add(smartPhone1);

		SmartPhone smartPhone2 = new SmartPhone();
		smartPhone2.setId(2L);
		smartPhone2.setName("SAMSUNG GALAXY S5 32GB");
		smartPhone2.setCpu("Qualcomm Snapdragon 2.5GHz");
		smartPhone2.setResWidth(1920);
		smartPhone2.setResHeight(1080);
		smartPhone2.setSystem("Android 4.4.2 Kitkat");
		smartPhones.add(smartPhone2);
	}
}
